package com.common.model;

import lombok.Builder;
import lombok.Data;

/**
 * 顶点
 *
 * @author think
 * @version 1.0.0
 * @since 2020/2/18
 */
@Data
@Builder
public class Vertex {

    /**
     * 顶点名称
     */
    private String name;
    /**
     * 顶点颜色
     */
    private Color color;
    /**
     * 父顶点
     */
    private Vertex parent;

    private int discover;
    private int finish;

    /**
     * 顶点编号
     */
    private int number;

    /**
     * 是否访问了
     */
    private boolean isVisted;

    /**
     * 链表
     */
    private Vertex nextNode;

    /**
     * 权重
     **/
    private int weight;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Vertex other = (Vertex) obj;
        if (name == null) {
            return other.name == null;
        } else {
            return name.equals(other.name);
        }
    }
}
